import net.sf.cglib.proxy.Enhancer;

public class Client {
    public static void main(String[] args) throws InterruptedException {
        // 创建代理CGLIB生成对象
        Enhancer enhancer = new Enhancer();
        // 设置被代理类
        enhancer.setSuperclass(OrderService.class);

        // 设置回调，相当于JDK动态代理的设置invocationHandler，我们在TimeMethodInterceptor的intercept方法中写了增强代码
        enhancer.setCallback(new TimeMethodInterceptor());

        // 获得代理对象，其实是CGLIB帮我们生成的子类
        OrderService orderService = (OrderService) enhancer.create();

        // 代理对象调用方法
        orderService.generateOrder();
        orderService.modifyOrder();
        orderService.deleteOrder();
    }
}
